package com.yq.practice.design.iterator;

import java.util.Iterator;

/**
 * @ClassName InfoIterator
 * @Description 信息学院是数组
 * @Author yaoqiang
 * @Date 2021/8/25 19:33
 * @Version 1.0
 */
public class InfoIterator implements Iterator {
    Department[] departments;
    int index=0;

    @Override
    public boolean hasNext() {
        if (index>=departments.length || departments[index]==null){
            return false;
        }else {
            return true;
        }
    }

    @Override
    public Object next() {
        Department department = departments[index];
        index+=1;
        return departments;
    }

    public InfoIterator(Department[] departments) {
        this.departments = departments;
    }
}
